# List all NMF models
nmfModel()
# or list only the built-in models
nmfModel(builtin.only=TRUE)
# create a NMF object based on one random matrix: the missing matrix is deduced
# Note this only works when using factory method NMF
n <- 50; r <- 3;
w <- matrix(runif(n*r), n, r)
nmfModel(W=w)
# create a NMF object based on random (compatible) matrices
p <- 20
h <- matrix(runif(r*p), r, p)
nmfModel(W=w, H=h)
# create a NMF object based on incompatible matrices: generate an error
h <- matrix(runif((r+1)*p), r+1, p)
new('NMFstd', W=w, H=h)
# same thing using the factory method: dimensions are corrected and a warning
# is thrown saying that the dimensions used are reduced
nmfModel(W=w, H=h)
# apply default NMF algorithm to a random target matrix
V <- matrix(runif(n*p), n, p)
nmf(V, r)Run the code above in your browser using DataLab